package com.itheima.stringbuilder_demo;

/*
    String 和 StringBuilder 相互转换

    String --> StringBuilder :
         public StringBuilder(String str) : 创建一个具有初始化内容的容器

    StringBuilder --> String :
        public String toString() : 把StringBuilder转成字符串


    "abc" --> StringBuilder --> reverse() --> String
 */
public class StringBuilderDemo3 {
    public static void main(String[] args) {
        // String s = "abc";

        //  String --> StringBuilder :
        //         public StringBuilder(String str) : 创建一个具有初始化内容的容器
        // StringBuilder sb = new StringBuilder(s);

        // StringBuilder --> String :
        //        public String toString() : 把StringBuilder转成字符串
        // String ss = sb.toString();

        //  "abc" --> StringBuilder --> reverse() --> String

//        String s = "abc";
//        // String -> StringBuilder
//        StringBuilder sb = new StringBuilder(s);// cba
//        //  对StringBuilder中元素反转
//        sb.reverse();
//        String ss = sb.toString();
//        System.out.println(ss);

        System.out.println(new StringBuilder("abc").reverse().toString());

    }
}
